# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[self.f = open(dev)
self.x = size[0]
self.y = size[1]
self.dx = self.x / 2
self.dy = self.y / 2
self.buttons = {'left': {'press': False, 'start': None, 'stop': None}, 'middle': {'press': False, 'start': None, 'stop': None}, 'right': {'press': False, 'start': None, 'stop': None}}
self.lastbutton = 0
self.lastvector = (0, 0)
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7682dcc>}
nname: 0
n 0(None)[return 'x:%d, y:%d, last_vec:%s, b:%s' % (self.dx, self.dy, self.lastvector, self.buttons)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb767f78c>}
nname: 847
n 847(None)[return 1
]:
	i: 834(), 846()
	o: 

nname: 846
n 846(None)[]:
	i: 439(f)
	o: 847()

nname: 834
n 834(None)[self.lastbutton = button
]:
	i: 733(JA), 783(), 833()
	o: 847()

nname: 833
n 833(None)[]:
	i: 712(f)
	o: 834()

nname: 783
n 783(None)[self.buttons['middle']['press'] = False
self.buttons['middle']['stop'] = [self.dx, self.dy]
]:
	i: 722(f)
	o: 834()

nname: 733
n 733(None)[self.buttons['middle']['press'] = True
self.buttons['middle']['start'] = [self.dx, self.dy]
]:
	i: 722(t)
	o: 834(JA)

nname: 722
n 722(button & 4)[]:
	i: 712(t)
	o: 733(t), 783(f)

nname: 712
n 712(change & 4)[]:
	i: 611(JA), 661(), 711()
	o: 722(t), 833(f)

nname: 711
n 711(None)[]:
	i: 590(f)
	o: 712()

nname: 661
n 661(None)[self.buttons['right']['press'] = False
self.buttons['right']['stop'] = [self.dx, self.dy]
]:
	i: 600(f)
	o: 712()

nname: 611
n 611(None)[self.buttons['right']['press'] = True
self.buttons['right']['start'] = [self.dx, self.dy]
]:
	i: 600(t)
	o: 712(JA)

nname: 600
n 600(button & 2)[]:
	i: 590(t)
	o: 611(t), 661(f)

nname: 590
n 590(change & 2)[]:
	i: 489(JA), 539(), 589()
	o: 600(t), 711(f)

nname: 589
n 589(None)[]:
	i: 454(f)
	o: 590()

nname: 539
n 539(None)[self.buttons['left']['press'] = False
self.buttons['left']['stop'] = [self.dx, self.dy]
]:
	i: 478(f)
	o: 590()

nname: 489
n 489(None)[self.buttons['left']['press'] = True
self.buttons['left']['start'] = [self.dx, self.dy]
]:
	i: 478(t)
	o: 590(JA)

nname: 478
n 478(button & 1)[]:
	i: 454(t)
	o: 489(t), 539(f)

nname: 454
n 454(change & 1)[change = self.lastbutton ^ button
]:
	i: 439(t)
	o: 478(t), 589(f)

nname: 439
n 439(self.lastbutton != button)[]:
	i: 422(), 438()
	o: 454(t), 846(f)

nname: 438
n 438(None)[]:
	i: 404(f)
	o: 439()

nname: 422
n 422(None)[self.dy = self.y
]:
	i: 404(t)
	o: 439()

nname: 404
n 404(self.dy > self.y)[]:
	i: 390(), 403()
	o: 422(t), 438(f)

nname: 403
n 403(None)[]:
	i: 359(f)
	o: 404()

nname: 390
n 390(None)[self.dy = 0
]:
	i: 359(t)
	o: 404()

nname: 359
n 359(self.dy < 0)[self.dy = self.dy - dy
]:
	i: 342(), 358()
	o: 390(t), 403(f)

nname: 358
n 358(None)[]:
	i: 324(f)
	o: 359()

nname: 342
n 342(None)[self.dx = self.x
]:
	i: 324(t)
	o: 359()

nname: 324
n 324(self.dx > self.x)[]:
	i: 310(), 323()
	o: 342(t), 358(f)

nname: 323
n 323(None)[]:
	i: 264(f)
	o: 324()

nname: 310
n 310(None)[self.dx = 0
]:
	i: 264(t)
	o: 324()

nname: 264
n 264(self.dx < 0)[self.lastvector = (dx, dy)
self.dx = self.dx + dx
]:
	i: 243(), 257()
	o: 310(t), 323(f)

nname: 257
n 257(None)[dy = c
]:
	i: 233(f)
	o: 264()

nname: 243
n 243(None)[dy = c - 256
]:
	i: 233(t)
	o: 264()

nname: 233
n 233(a & 32)[]:
	i: 212(), 226()
	o: 243(t), 257(f)

nname: 226
n 226(None)[dx = b
]:
	i: 192(f)
	o: 233()

nname: 212
n 212(None)[dx = b - 256
]:
	i: 192(t)
	o: 233()

nname: 192
n 192(a & 16)[button = a & 7
]:
	i: 183(), 191()
	o: 212(t), 226(f)

nname: 191
n 191(None)[]:
	i: 173(t)
	o: 192()

nname: 183
n 183(None)[return 0
]:
	i: 173(f)
	o: 192()

nname: 173
n 173(a & 8)[]:
	i: 164(), 172()
	o: 183(f), 191(t)

nname: 172
n 172(None)[]:
	i: 76(f)
	o: 173()

nname: 164
n 164(None)[return 0
]:
	i: 76(t)
	o: 173()

nname: 76
n 76(a & 192)[dx = 0
dy = 0
buf = self.f.read(3)
a = ord(buf[0])
b = ord(buf[1])
c = ord(buf[2])
]:
	i: 0(AL), 75()
	o: 164(t), 172(f)

nname: 75
n 75(None)[]:
	i: 3(AF), 71()
	o: 76()

nname: 71
n 71(None)[]:
	i: 13(t), 33()
	o: 75()

nname: 33
n 33(None)[self.buttons[a]['start'] = None
self.buttons[a]['stop'] = None
continue
]:
	i: 13(f)
	o: 71()

nname: 13
n 13(self.buttons[a]['press'])[for a in self.buttons:
]:
	i: 3(for)
	o: 33(f), 71(t)

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 13(for), 75(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 76(AL)

nname: 847
n 847(None)[return 1
]:
	i: 712(), 439(f)
	o: 

nname: 712
n 712(None)[if change & 4:
	if button & 4:
		self.buttons['middle']['press'] = True
		self.buttons['middle']['start'] = [self.dx, self.dy]
	else:
		self.buttons['middle']['press'] = False
		self.buttons['middle']['stop'] = [self.dx, self.dy]
self.lastbutton = button
]:
	i: 454(JA)
	o: 847()

nname: 454
n 454(None)[change = self.lastbutton ^ button
if change & 1:
	if button & 1:
		self.buttons['left']['press'] = True
		self.buttons['left']['start'] = [self.dx, self.dy]
	else:
		self.buttons['left']['press'] = False
		self.buttons['left']['stop'] = [self.dx, self.dy]
if change & 2:
	if button & 2:
		self.buttons['right']['press'] = True
		self.buttons['right']['start'] = [self.dx, self.dy]
	else:
		self.buttons['right']['press'] = False
		self.buttons['right']['stop'] = [self.dx, self.dy]
]:
	i: 439(t)
	o: 712(JA)

nname: 439
n 439(self.lastbutton != button)[]:
	i: 359()
	o: 454(t), 847(f)

nname: 359
n 359(None)[self.dy = self.dy - dy
if self.dy < 0:
	self.dy = 0
if self.dy > self.y:
	self.dy = self.y
]:
	i: 264()
	o: 439()

nname: 264
n 264(None)[self.lastvector = (dx, dy)
self.dx = self.dx + dx
if self.dx < 0:
	self.dx = 0
if self.dx > self.x:
	self.dx = self.x
]:
	i: 192()
	o: 359()

nname: 192
n 192(None)[button = a & 7
if a & 16:
	dx = b - 256
else:
	dx = b
if a & 32:
	dy = c - 256
else:
	dy = c
]:
	i: 76()
	o: 264()

nname: 76
n 76(None)[dx = 0
dy = 0
buf = self.f.read(3)
a = ord(buf[0])
b = ord(buf[1])
c = ord(buf[2])
if a & 192:
	return 0
if not a & 8:
	return 0
]:
	i: 0(AL), 3(AF), 13()
	o: 192()

nname: 13
n 13(None)[for a in self.buttons:
if not self.buttons[a]['press']:
	self.buttons[a]['start'] = None
	self.buttons[a]['stop'] = None
	continue
]:
	i: 3(for)
	o: 76()

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 13(for), 76(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 76(AL)

nname: 847
n 847(None)[return 1
]:
	i: 454(), 359(f)
	o: 

nname: 454
n 454(None)[change = self.lastbutton ^ button
if change & 1:
	if button & 1:
		self.buttons['left']['press'] = True
		self.buttons['left']['start'] = [self.dx, self.dy]
	else:
		self.buttons['left']['press'] = False
		self.buttons['left']['stop'] = [self.dx, self.dy]
if change & 2:
	if button & 2:
		self.buttons['right']['press'] = True
		self.buttons['right']['start'] = [self.dx, self.dy]
	else:
		self.buttons['right']['press'] = False
		self.buttons['right']['stop'] = [self.dx, self.dy]
if change & 4:
	if button & 4:
		self.buttons['middle']['press'] = True
		self.buttons['middle']['start'] = [self.dx, self.dy]
	else:
		self.buttons['middle']['press'] = False
		self.buttons['middle']['stop'] = [self.dx, self.dy]
self.lastbutton = button
]:
	i: 359(t)
	o: 847()

nname: 359
n 359(self.lastbutton != button)[self.dy = self.dy - dy
if self.dy < 0:
	self.dy = 0
if self.dy > self.y:
	self.dy = self.y
]:
	i: 192()
	o: 454(t), 847(f)

nname: 192
n 192(None)[button = a & 7
if a & 16:
	dx = b - 256
else:
	dx = b
if a & 32:
	dy = c - 256
else:
	dy = c
self.lastvector = (dx, dy)
self.dx = self.dx + dx
if self.dx < 0:
	self.dx = 0
if self.dx > self.x:
	self.dx = self.x
]:
	i: 13()
	o: 359()

nname: 13
n 13(None)[for a in self.buttons:
	if not self.buttons[a]['press']:
		self.buttons[a]['start'] = None
		self.buttons[a]['stop'] = None
		continue
dx = 0
dy = 0
buf = self.f.read(3)
a = ord(buf[0])
b = ord(buf[1])
c = ord(buf[2])
if a & 192:
	return 0
if not a & 8:
	return 0
]:
	i: 0(for)
	o: 192()

nname: 0
n 0(None)[]:
	i: 
	o: 13(for)

nname: 847
n 847(None)[return 1
]:
	i: 192(f)
	o: 

nname: 192
n 192(None)[button = a & 7
if a & 16:
	dx = b - 256
else:
	dx = b
if a & 32:
	dy = c - 256
else:
	dy = c
self.lastvector = (dx, dy)
self.dx = self.dx + dx
if self.dx < 0:
	self.dx = 0
if self.dx > self.x:
	self.dx = self.x
self.dy = self.dy - dy
if self.dy < 0:
	self.dy = 0
if self.dy > self.y:
	self.dy = self.y
if self.lastbutton != button:
	change = self.lastbutton ^ button
	if change & 1:
		if button & 1:
			self.buttons['left']['press'] = True
			self.buttons['left']['start'] = [self.dx, self.dy]
		else:
			self.buttons['left']['press'] = False
			self.buttons['left']['stop'] = [self.dx, self.dy]
	if change & 2:
		if button & 2:
			self.buttons['right']['press'] = True
			self.buttons['right']['start'] = [self.dx, self.dy]
		else:
			self.buttons['right']['press'] = False
			self.buttons['right']['stop'] = [self.dx, self.dy]
	if change & 4:
		if button & 4:
			self.buttons['middle']['press'] = True
			self.buttons['middle']['start'] = [self.dx, self.dy]
		else:
			self.buttons['middle']['press'] = False
			self.buttons['middle']['stop'] = [self.dx, self.dy]
	self.lastbutton = button
]:
	i: 0()
	o: 847()

nname: 0
n 0(None)[for a in self.buttons:
	if not self.buttons[a]['press']:
		self.buttons[a]['start'] = None
		self.buttons[a]['stop'] = None
		continue
dx = 0
dy = 0
buf = self.f.read(3)
a = ord(buf[0])
b = ord(buf[1])
c = ord(buf[2])
if a & 192:
	return 0
if not a & 8:
	return 0
]:
	i: 
	o: 192()

nname: 847
n 847(None)[return 1
]:
	i: 0(f)
	o: 

nname: 0
n 0(None)[for a in self.buttons:
	if not self.buttons[a]['press']:
		self.buttons[a]['start'] = None
		self.buttons[a]['stop'] = None
		continue
dx = 0
dy = 0
buf = self.f.read(3)
a = ord(buf[0])
b = ord(buf[1])
c = ord(buf[2])
if a & 192:
	return 0
if not a & 8:
	return 0
button = a & 7
if a & 16:
	dx = b - 256
else:
	dx = b
if a & 32:
	dy = c - 256
else:
	dy = c
self.lastvector = (dx, dy)
self.dx = self.dx + dx
if self.dx < 0:
	self.dx = 0
if self.dx > self.x:
	self.dx = self.x
self.dy = self.dy - dy
if self.dy < 0:
	self.dy = 0
if self.dy > self.y:
	self.dy = self.y
if self.lastbutton != button:
	change = self.lastbutton ^ button
	if change & 1:
		if button & 1:
			self.buttons['left']['press'] = True
			self.buttons['left']['start'] = [self.dx, self.dy]
		else:
			self.buttons['left']['press'] = False
			self.buttons['left']['stop'] = [self.dx, self.dy]
	if change & 2:
		if button & 2:
			self.buttons['right']['press'] = True
			self.buttons['right']['start'] = [self.dx, self.dy]
		else:
			self.buttons['right']['press'] = False
			self.buttons['right']['stop'] = [self.dx, self.dy]
	if change & 4:
		if button & 4:
			self.buttons['middle']['press'] = True
			self.buttons['middle']['start'] = [self.dx, self.dy]
		else:
			self.buttons['middle']['press'] = False
			self.buttons['middle']['stop'] = [self.dx, self.dy]
	self.lastbutton = button
]:
	i: 
	o: 847()

nname: 0
n 0(None)[for a in self.buttons:
	if not self.buttons[a]['press']:
		self.buttons[a]['start'] = None
		self.buttons[a]['stop'] = None
		continue
dx = 0
dy = 0
buf = self.f.read(3)
a = ord(buf[0])
b = ord(buf[1])
c = ord(buf[2])
if a & 192:
	return 0
if not a & 8:
	return 0
button = a & 7
if a & 16:
	dx = b - 256
else:
	dx = b
if a & 32:
	dy = c - 256
else:
	dy = c
self.lastvector = (dx, dy)
self.dx = self.dx + dx
if self.dx < 0:
	self.dx = 0
if self.dx > self.x:
	self.dx = self.x
self.dy = self.dy - dy
if self.dy < 0:
	self.dy = 0
if self.dy > self.y:
	self.dy = self.y
if self.lastbutton != button:
	change = self.lastbutton ^ button
	if change & 1:
		if button & 1:
			self.buttons['left']['press'] = True
			self.buttons['left']['start'] = [self.dx, self.dy]
		else:
			self.buttons['left']['press'] = False
			self.buttons['left']['stop'] = [self.dx, self.dy]
	if change & 2:
		if button & 2:
			self.buttons['right']['press'] = True
			self.buttons['right']['start'] = [self.dx, self.dy]
		else:
			self.buttons['right']['press'] = False
			self.buttons['right']['stop'] = [self.dx, self.dy]
	if change & 4:
		if button & 4:
			self.buttons['middle']['press'] = True
			self.buttons['middle']['start'] = [self.dx, self.dy]
		else:
			self.buttons['middle']['press'] = False
			self.buttons['middle']['stop'] = [self.dx, self.dy]
	self.lastbutton = button
return 1
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb768c7ac>}
nname: 6
n 6(None)[def __init__(self, size=(1280, 720), dev='/dev/input/mice'):
	self.f = open(dev)
	self.x = size[0]
	self.y = size[1]
	self.dx = self.x / 2
	self.dy = self.y / 2
	self.buttons = {'left': {'press': False, 'start': None, 'stop': None}, 'middle': {'press': False, 'start': None, 'stop': None}, 'right': {'press': False, 'start': None, 'stop': None}}
	self.lastbutton = 0
	self.lastvector = (0, 0)
	return None

def __str__(self):
	return 'x:%d, y:%d, last_vec:%s, b:%s' % (self.dx, self.dy, self.lastvector, self.buttons)

def get(self):
	for a in self.buttons:
		if not self.buttons[a]['press']:
			self.buttons[a]['start'] = None
			self.buttons[a]['stop'] = None
			continue
	dx = 0
	dy = 0
	buf = self.f.read(3)
	a = ord(buf[0])
	b = ord(buf[1])
	c = ord(buf[2])
	if a & 192:
		return 0
	if not a & 8:
		return 0
	button = a & 7
	if a & 16:
		dx = b - 256
	else:
		dx = b
	if a & 32:
		dy = c - 256
	else:
		dy = c
	self.lastvector = (dx, dy)
	self.dx = self.dx + dx
	if self.dx < 0:
		self.dx = 0
	if self.dx > self.x:
		self.dx = self.x
	self.dy = self.dy - dy
	if self.dy < 0:
		self.dy = 0
	if self.dy > self.y:
		self.dy = self.y
	if self.lastbutton != button:
		change = self.lastbutton ^ button
		if change & 1:
			if button & 1:
				self.buttons['left']['press'] = True
				self.buttons['left']['start'] = [self.dx, self.dy]
			else:
				self.buttons['left']['press'] = False
				self.buttons['left']['stop'] = [self.dx, self.dy]
		if change & 2:
			if button & 2:
				self.buttons['right']['press'] = True
				self.buttons['right']['start'] = [self.dx, self.dy]
			else:
				self.buttons['right']['press'] = False
				self.buttons['right']['stop'] = [self.dx, self.dy]
		if change & 4:
			if button & 4:
				self.buttons['middle']['press'] = True
				self.buttons['middle']['start'] = [self.dx, self.dy]
			else:
				self.buttons['middle']['press'] = False
				self.buttons['middle']['stop'] = [self.dx, self.dy]
		self.lastbutton = button
	return 1

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb767f10c>}
nname: 149
n 149(None)[]:
	i: 117(AL), 141(), 148()
	o: 

nname: 148
n 148(None)[]:
	i: 0(f)
	o: 149()

nname: 141
n 141(None)[]:
	i: 120(f), 132()
	o: 149()

nname: 132
n 132(None)[print m
continue
]:
	i: 120(t)
	o: 141()

nname: 120
n 120(m.get())[]:
	i: 117(loop)
	o: 132(t), 141(f)

nname: 117
n 117(None)[]:
	i: 81(), 107()
	o: 120(loop), 149(AL)

nname: 107
n 107(None)[m = Mouse()
]:
	i: 47(f)
	o: 117()

nname: 81
n 81(None)[m = Mouse(dev=sys.argv[1])
]:
	i: 47(t)
	o: 117()

nname: 47
n 47(len(sys.argv) > 1)[import sys
]:
	i: 0(t)
	o: 81(t), 107(f)

nname: 0
n 0(__name__ == '__main__')[from __future__ import absolute_import
class Mouse():
	def __init__(self, size=(1280, 720), dev='/dev/input/mice'):
		self.f = open(dev)
		self.x = size[0]
		self.y = size[1]
		self.dx = self.x / 2
		self.dy = self.y / 2
		self.buttons = {'left': {'press': False, 'start': None, 'stop': None}, 'middle': {'press': False, 'start': None, 'stop': None}, 'right': {'press': False, 'start': None, 'stop': None}}
		self.lastbutton = 0
		self.lastvector = (0, 0)
		return None

	def __str__(self):
		return 'x:%d, y:%d, last_vec:%s, b:%s' % (self.dx, self.dy, self.lastvector, self.buttons)

	def get(self):
		for a in self.buttons:
			if not self.buttons[a]['press']:
				self.buttons[a]['start'] = None
				self.buttons[a]['stop'] = None
				continue
		dx = 0
		dy = 0
		buf = self.f.read(3)
		a = ord(buf[0])
		b = ord(buf[1])
		c = ord(buf[2])
		if a & 192:
			return 0
		if not a & 8:
			return 0
		button = a & 7
		if a & 16:
			dx = b - 256
		else:
			dx = b
		if a & 32:
			dy = c - 256
		else:
			dy = c
		self.lastvector = (dx, dy)
		self.dx = self.dx + dx
		if self.dx < 0:
			self.dx = 0
		if self.dx > self.x:
			self.dx = self.x
		self.dy = self.dy - dy
		if self.dy < 0:
			self.dy = 0
		if self.dy > self.y:
			self.dy = self.y
		if self.lastbutton != button:
			change = self.lastbutton ^ button
			if change & 1:
				if button & 1:
					self.buttons['left']['press'] = True
					self.buttons['left']['start'] = [self.dx, self.dy]
				else:
					self.buttons['left']['press'] = False
					self.buttons['left']['stop'] = [self.dx, self.dy]
			if change & 2:
				if button & 2:
					self.buttons['right']['press'] = True
					self.buttons['right']['start'] = [self.dx, self.dy]
				else:
					self.buttons['right']['press'] = False
					self.buttons['right']['stop'] = [self.dx, self.dy]
			if change & 4:
				if button & 4:
					self.buttons['middle']['press'] = True
					self.buttons['middle']['start'] = [self.dx, self.dy]
				else:
					self.buttons['middle']['press'] = False
					self.buttons['middle']['stop'] = [self.dx, self.dy]
			self.lastbutton = button
		return 1



]:
	i: 
	o: 47(t), 148(f)

nname: 149
n 149(None)[]:
	i: 120(), 0(f)
	o: 

nname: 120
n 120(None)[while m.get():
	print m
	continue
]:
	i: 47(loop)
	o: 149()

nname: 47
n 47(None)[import sys
if len(sys.argv) > 1:
	m = Mouse(dev=sys.argv[1])
else:
	m = Mouse()
]:
	i: 0(t)
	o: 120(loop)

nname: 0
n 0(__name__ == '__main__')[from __future__ import absolute_import
class Mouse():
	def __init__(self, size=(1280, 720), dev='/dev/input/mice'):
		self.f = open(dev)
		self.x = size[0]
		self.y = size[1]
		self.dx = self.x / 2
		self.dy = self.y / 2
		self.buttons = {'left': {'press': False, 'start': None, 'stop': None}, 'middle': {'press': False, 'start': None, 'stop': None}, 'right': {'press': False, 'start': None, 'stop': None}}
		self.lastbutton = 0
		self.lastvector = (0, 0)
		return None

	def __str__(self):
		return 'x:%d, y:%d, last_vec:%s, b:%s' % (self.dx, self.dy, self.lastvector, self.buttons)

	def get(self):
		for a in self.buttons:
			if not self.buttons[a]['press']:
				self.buttons[a]['start'] = None
				self.buttons[a]['stop'] = None
				continue
		dx = 0
		dy = 0
		buf = self.f.read(3)
		a = ord(buf[0])
		b = ord(buf[1])
		c = ord(buf[2])
		if a & 192:
			return 0
		if not a & 8:
			return 0
		button = a & 7
		if a & 16:
			dx = b - 256
		else:
			dx = b
		if a & 32:
			dy = c - 256
		else:
			dy = c
		self.lastvector = (dx, dy)
		self.dx = self.dx + dx
		if self.dx < 0:
			self.dx = 0
		if self.dx > self.x:
			self.dx = self.x
		self.dy = self.dy - dy
		if self.dy < 0:
			self.dy = 0
		if self.dy > self.y:
			self.dy = self.y
		if self.lastbutton != button:
			change = self.lastbutton ^ button
			if change & 1:
				if button & 1:
					self.buttons['left']['press'] = True
					self.buttons['left']['start'] = [self.dx, self.dy]
				else:
					self.buttons['left']['press'] = False
					self.buttons['left']['stop'] = [self.dx, self.dy]
			if change & 2:
				if button & 2:
					self.buttons['right']['press'] = True
					self.buttons['right']['start'] = [self.dx, self.dy]
				else:
					self.buttons['right']['press'] = False
					self.buttons['right']['stop'] = [self.dx, self.dy]
			if change & 4:
				if button & 4:
					self.buttons['middle']['press'] = True
					self.buttons['middle']['start'] = [self.dx, self.dy]
				else:
					self.buttons['middle']['press'] = False
					self.buttons['middle']['stop'] = [self.dx, self.dy]
			self.lastbutton = button
		return 1



]:
	i: 
	o: 47(t), 149(f)

nname: 149
n 149(None)[]:
	i: 47(), 0(f)
	o: 

nname: 47
n 47(None)[import sys
if len(sys.argv) > 1:
	m = Mouse(dev=sys.argv[1])
else:
	m = Mouse()
while m.get():
	print m
	continue
]:
	i: 0(t)
	o: 149()

nname: 0
n 0(__name__ == '__main__')[from __future__ import absolute_import
class Mouse():
	def __init__(self, size=(1280, 720), dev='/dev/input/mice'):
		self.f = open(dev)
		self.x = size[0]
		self.y = size[1]
		self.dx = self.x / 2
		self.dy = self.y / 2
		self.buttons = {'left': {'press': False, 'start': None, 'stop': None}, 'middle': {'press': False, 'start': None, 'stop': None}, 'right': {'press': False, 'start': None, 'stop': None}}
		self.lastbutton = 0
		self.lastvector = (0, 0)
		return None

	def __str__(self):
		return 'x:%d, y:%d, last_vec:%s, b:%s' % (self.dx, self.dy, self.lastvector, self.buttons)

	def get(self):
		for a in self.buttons:
			if not self.buttons[a]['press']:
				self.buttons[a]['start'] = None
				self.buttons[a]['stop'] = None
				continue
		dx = 0
		dy = 0
		buf = self.f.read(3)
		a = ord(buf[0])
		b = ord(buf[1])
		c = ord(buf[2])
		if a & 192:
			return 0
		if not a & 8:
			return 0
		button = a & 7
		if a & 16:
			dx = b - 256
		else:
			dx = b
		if a & 32:
			dy = c - 256
		else:
			dy = c
		self.lastvector = (dx, dy)
		self.dx = self.dx + dx
		if self.dx < 0:
			self.dx = 0
		if self.dx > self.x:
			self.dx = self.x
		self.dy = self.dy - dy
		if self.dy < 0:
			self.dy = 0
		if self.dy > self.y:
			self.dy = self.y
		if self.lastbutton != button:
			change = self.lastbutton ^ button
			if change & 1:
				if button & 1:
					self.buttons['left']['press'] = True
					self.buttons['left']['start'] = [self.dx, self.dy]
				else:
					self.buttons['left']['press'] = False
					self.buttons['left']['stop'] = [self.dx, self.dy]
			if change & 2:
				if button & 2:
					self.buttons['right']['press'] = True
					self.buttons['right']['start'] = [self.dx, self.dy]
				else:
					self.buttons['right']['press'] = False
					self.buttons['right']['stop'] = [self.dx, self.dy]
			if change & 4:
				if button & 4:
					self.buttons['middle']['press'] = True
					self.buttons['middle']['start'] = [self.dx, self.dy]
				else:
					self.buttons['middle']['press'] = False
					self.buttons['middle']['stop'] = [self.dx, self.dy]
			self.lastbutton = button
		return 1



]:
	i: 
	o: 47(t), 149(f)

nname: 0
n 0(None)[from __future__ import absolute_import
class Mouse():
	def __init__(self, size=(1280, 720), dev='/dev/input/mice'):
		self.f = open(dev)
		self.x = size[0]
		self.y = size[1]
		self.dx = self.x / 2
		self.dy = self.y / 2
		self.buttons = {'left': {'press': False, 'start': None, 'stop': None}, 'middle': {'press': False, 'start': None, 'stop': None}, 'right': {'press': False, 'start': None, 'stop': None}}
		self.lastbutton = 0
		self.lastvector = (0, 0)
		return None

	def __str__(self):
		return 'x:%d, y:%d, last_vec:%s, b:%s' % (self.dx, self.dy, self.lastvector, self.buttons)

	def get(self):
		for a in self.buttons:
			if not self.buttons[a]['press']:
				self.buttons[a]['start'] = None
				self.buttons[a]['stop'] = None
				continue
		dx = 0
		dy = 0
		buf = self.f.read(3)
		a = ord(buf[0])
		b = ord(buf[1])
		c = ord(buf[2])
		if a & 192:
			return 0
		if not a & 8:
			return 0
		button = a & 7
		if a & 16:
			dx = b - 256
		else:
			dx = b
		if a & 32:
			dy = c - 256
		else:
			dy = c
		self.lastvector = (dx, dy)
		self.dx = self.dx + dx
		if self.dx < 0:
			self.dx = 0
		if self.dx > self.x:
			self.dx = self.x
		self.dy = self.dy - dy
		if self.dy < 0:
			self.dy = 0
		if self.dy > self.y:
			self.dy = self.y
		if self.lastbutton != button:
			change = self.lastbutton ^ button
			if change & 1:
				if button & 1:
					self.buttons['left']['press'] = True
					self.buttons['left']['start'] = [self.dx, self.dy]
				else:
					self.buttons['left']['press'] = False
					self.buttons['left']['stop'] = [self.dx, self.dy]
			if change & 2:
				if button & 2:
					self.buttons['right']['press'] = True
					self.buttons['right']['start'] = [self.dx, self.dy]
				else:
					self.buttons['right']['press'] = False
					self.buttons['right']['stop'] = [self.dx, self.dy]
			if change & 4:
				if button & 4:
					self.buttons['middle']['press'] = True
					self.buttons['middle']['start'] = [self.dx, self.dy]
				else:
					self.buttons['middle']['press'] = False
					self.buttons['middle']['stop'] = [self.dx, self.dy]
			self.lastbutton = button
		return 1



if __name__ == '__main__':
	import sys
	if len(sys.argv) > 1:
		m = Mouse(dev=sys.argv[1])
	else:
		m = Mouse()
	while m.get():
		print m
		continue
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7671f0c>}
from __future__ import absolute_import
class Mouse():
	def __init__(self, size=(1280, 720), dev='/dev/input/mice'):
		self.f = open(dev)
		self.x = size[0]
		self.y = size[1]
		self.dx = self.x / 2
		self.dy = self.y / 2
		self.buttons = {'left': {'press': False, 'start': None, 'stop': None}, 'middle': {'press': False, 'start': None, 'stop': None}, 'right': {'press': False, 'start': None, 'stop': None}}
		self.lastbutton = 0
		self.lastvector = (0, 0)
		return None

	def __str__(self):
		return 'x:%d, y:%d, last_vec:%s, b:%s' % (self.dx, self.dy, self.lastvector, self.buttons)

	def get(self):
		for a in self.buttons:
			if not self.buttons[a]['press']:
				self.buttons[a]['start'] = None
				self.buttons[a]['stop'] = None
				continue
		dx = 0
		dy = 0
		buf = self.f.read(3)
		a = ord(buf[0])
		b = ord(buf[1])
		c = ord(buf[2])
		if a & 192:
			return 0
		if not a & 8:
			return 0
		button = a & 7
		if a & 16:
			dx = b - 256
		else:
			dx = b
		if a & 32:
			dy = c - 256
		else:
			dy = c
		self.lastvector = (dx, dy)
		self.dx = self.dx + dx
		if self.dx < 0:
			self.dx = 0
		if self.dx > self.x:
			self.dx = self.x
		self.dy = self.dy - dy
		if self.dy < 0:
			self.dy = 0
		if self.dy > self.y:
			self.dy = self.y
		if self.lastbutton != button:
			change = self.lastbutton ^ button
			if change & 1:
				if button & 1:
					self.buttons['left']['press'] = True
					self.buttons['left']['start'] = [self.dx, self.dy]
				else:
					self.buttons['left']['press'] = False
					self.buttons['left']['stop'] = [self.dx, self.dy]
			if change & 2:
				if button & 2:
					self.buttons['right']['press'] = True
					self.buttons['right']['start'] = [self.dx, self.dy]
				else:
					self.buttons['right']['press'] = False
					self.buttons['right']['stop'] = [self.dx, self.dy]
			if change & 4:
				if button & 4:
					self.buttons['middle']['press'] = True
					self.buttons['middle']['start'] = [self.dx, self.dy]
				else:
					self.buttons['middle']['press'] = False
					self.buttons['middle']['stop'] = [self.dx, self.dy]
			self.lastbutton = button
		return 1



if __name__ == '__main__':
	import sys
	if len(sys.argv) > 1:
		m = Mouse(dev=sys.argv[1])
	else:
		m = Mouse()
	while m.get():
		print m
		continue
